import 'package:flutter/material.dart';
import 'package:islandingclub/constants/hero_constants.dart';
import 'package:islandingclub/constants/image_constants.dart';
import 'package:islandingclub/utils/extensions.dart';

class AnimatedLogo extends StatelessWidget {
  AnimatedLogo({Key key, @required this.controller}) : super(key: key) {
    bigger = Tween<double>(begin: 80.w, end: 110.w).animate(
      CurvedAnimation(
        parent: controller,
        curve: Interval(
          0.0,
          0.4,
          curve: Curves.ease,
        ),
      ),
    );
    smaller = Tween<double>(begin: 0.w, end: 30.w).animate(
      CurvedAnimation(
        parent: controller,
        curve: Interval(
          0.4,
          0.8,
          curve: Curves.ease,
        ),
      ),
    );
    scale = Tween<double>(begin: 1.0, end: 30.0).animate(
      CurvedAnimation(
        parent: controller,
        curve: Interval(
          0.8,
          1.0,
          curve: Curves.ease,
        ),
      ),
    );
  }

  final Animation<double> controller;
  Animation<double> bigger;
  Animation<double> smaller;
  Animation<double> scale;

  @override
  Widget build(BuildContext context) {
    return ScaleTransition(
      scale: scale,
      child: AnimatedBuilder(
        animation: controller,
        builder: (context, child) => Hero(
          tag: HeroConstants.SPLASH_LOGO,
          child: Image.asset(
            ImageConstants.logo,
            width: bigger.value - smaller.value,
            height: bigger.value - smaller.value,
          ),
        ),
      ),
    );
  }
}
